package demo;

import java.io.IOException;

import javax.enterprise.event.Observes;
import javax.inject.Inject;

import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.rapidpm.demo.cdi.commons.fx.CDIStartupScene;
import org.rapidpm.demo.cdi.commons.fx.FXMLLoaderSingleton;

/**
 * User: Sven Ruppert
 * Date: 09.07.13
 * Time: 12:03
 */
public class LoginApplicationStarter {

    @Inject
    private FXMLLoaderSingleton fxmlLoaderSingleton;

    public void launchJavaFXApplication(@Observes @CDIStartupScene Stage s) {
        try {
            Parent root = (Parent) fxmlLoaderSingleton.getFXMLLoader(LoginPane.class).load();
            s.setTitle("Login");
            s.setScene(new Scene(root, 300, 275));
            s.show();
        } catch (IOException e) {
            throw new IllegalStateException("cannot load FXML login screen", e);
        } finally {

        }
    }
}
